package com.miciyun.springbootrabbitmqdemo.demos.service;

import com.miciyun.springbootrabbitmqdemo.demos.entity.NoticeMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.miciyun.springbootrabbitmqdemo.demos.constant.RabbitTopicApiEnum.EXCHANGE_NAME;
import static com.miciyun.springbootrabbitmqdemo.demos.constant.RabbitTopicApiEnum.NOTICE_MSG_ROUTE_KEY;

/**
 * @author mctec
 */
@Component
public class RabbitTopicSendService {
    @Resource
    RabbitTemplate rabbitTemplate;

    public void sendNoticeMessage(NoticeMessage noticeMessage){
        rabbitTemplate.convertAndSend(EXCHANGE_NAME.content(), NOTICE_MSG_ROUTE_KEY.content()+".send", noticeMessage);
    }
}
